//
//  TrainingGroupRow.swift
//  Fitness
//
//  Created by duanwenpu on 2021/9/10.
//

import SwiftUI

typealias AddActionBlock = (Int) -> ()

struct TrainingGroupRow: View {
    @State var trainingGroup: TrainingGroupModel
    @State var edit: Bool = false
    var addActionCallBack: AddActionBlock
    func addEmptyActionRow() {
        withUnsafePointer(to: &trainingGroup) {ptr in print("====\(ptr)")}
        addActionCallBack(trainingGroup.id)
//        self.trainingGroup.trainingArray.append(TrainingModel(id: 2, actionName: "请输入", actionTimes: "0", perWeight: "0", restTime: "0"))
    }
    var body: some View {
        VStack(alignment: .leading, spacing: 10, content: {
            HStack(alignment: .center, spacing: 10, content: {
                Text(trainingGroup.groupName)
                Button(action: {
                    
                    addEmptyActionRow()
                }, label: {
                    Text("添加action")
                })
                .disabled(!edit)
            })
//            List(trainingGroup.trainingArray) { trainingModel in
//                TrainingActionRow(trainingModel: trainingModel, edit: edit)
//            }
        })

    }
}
